package com.xuebaopeng.xbp.core;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.xuebaopeng.xbp.constants.AppStatusTracker;
import com.xuebaopeng.xbp.constants.ConstantValues;
import com.xuebaopeng.xbp.sample.HomeActivity;

/**
 * ****************************************
 * Created by xbp on 2016/7/13.
 *  activity 基类
 * ****************************************
 */
public class BaseActivity  extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        switch (AppStatusTracker.getInstance().getAppStatus()) {
            case ConstantValues.STATUS_FORCE_KILLED:
                protectApp();
                break;
            case ConstantValues.STATUS_KICK_OUT:
                kickOut();
                break;
            case ConstantValues.STATUS_LOGOUT:
            case ConstantValues.STATUS_OFFLINE:
            case ConstantValues.STATUS_ONLINE:
                setUpData();
                break;
        }
    }

    //初始化数据
    protected void setUpData() {

    }

    protected void protectApp() {
        Intent intent=new Intent(this, HomeActivity.class);
        intent.putExtra(ConstantValues.KEY_HOME_ACTION, ConstantValues.ACTION_RESTART_APP);
        startActivity(intent);
    }
    protected void kickOut() {
        Intent intent = new Intent(this, HomeActivity.class);
        intent.putExtra(ConstantValues.KEY_HOME_ACTION, ConstantValues.ACTION_KICK_OUT);
        startActivity(intent);
    }

    @Override
    protected void onStart() {
        super.onStart();
        //解锁调到锁屏页面
        if(AppStatusTracker.getInstance().checkIfShowGesture()){
            //startActivity(new Intent());
        }
    }
}
